import { Redirect } from 'umi';
import React from 'react';

export default (props) => {
  let token = localStorage.getItem('token') || '';
  let persist = localStorage.getItem('persist:doctor') || '{}';
  persist = JSON.parse(persist);
  const { menusPath = [] } = persist.global || {};
  const { pathname = '' } = props.location;
  if (!token) {
    return <Redirect to="/" />;
  }
  // if (pathname != '/common/404' && menusPath.indexOf(pathname)< 0) {
  //   return <Redirect to="/common/404" />;
  // }
  console.log('props', menusPath, pathname);
  return <React.Fragment>{props.children}</React.Fragment>;
};
